{include file="pageheader_erp.htm"}

{include file="erp_goods_search.htm"}

{insert_scripts files="../js/jquery.1.3.2.js"}
{insert_scripts files="../js/jquery.blockUI.2.23.js"}

<style type="text/css">
	.current_page_style
	{
		color:red;
		font-weight:bold;
	}
	
</style>

{if $edit eq 1}
<script type="text/javascript">
	
	$(document).ready(function(){
		
		$("span[id^='span_set_warn_number_']").mouseover(function(){
			$(this).css('color','red');
		});
		
		$("span[id^='span_set_warn_number_']").mouseout(function(){
			$(this).css('color','black');
		});
		
		$("span[id^='span_set_warn_number_']").css('cursor','hand');
		
		$("span[id^='span_set_warn_number_']").click(function(){
			var goods_id=$(this).attr('id');
			goods_id=goods_id.substr('span_set_warn_number_'.length,goods_id.length-'span_set_warn_number_'.length);
			
			$("#span_warn_number_"+goods_id).hide();
			$("#input_warn_number_"+goods_id).show().focus();
		});
		
		$("input[id^='input_warn_number_']").blur(function(){
			var goods_id=$(this).attr('id');
			goods_id=goods_id.substr('input_warn_number_'.length,goods_id.length-'input_warn_number_'.length);		
			
			$(this).hide();
			$("#span_warn_number_"+goods_id).show();	
		});
		
		$("input[id^='input_warn_number_']").change(function(){
			var goods_id=$(this).attr('id');
			goods_id=goods_id.substr('input_warn_number_'.length,goods_id.length-'input_warn_number_'.length);				
			
			var warn_number=$(this).attr('value');
			
			function setWarnNumberResponse(res)
			{
				if(res.error!=0)
				{
					alert(res.message);
				}
				else
				{
					window.location='{$url}';
				}
			}
			
			if(isNaN(warn_number))
			{
				alert('{$lang.erp_not_a_number}');
			}
			else{
				if(confirm('{$lang.erp_goods_list_sure_to_change_warn_number}'))
				{
					warn_number=parseInt(warn_number);
					Ajax.call('erp_goods_list.php?act=set_warn_number', 'goods_id='+goods_id+'&warn_number='+warn_number, setWarnNumberResponse, 'POST', 'JSON');
				}
				else
				{
					$(this).attr('value',$("#span_warn_number_"+goods_id).text());
					$(this).hide();
					$("#span_warn_number_"+goods_id).show();
				}				
			}
		});
				
		$("span[id^='span_warn_number_']").css('cursor','hand');
		$("span[id^='span_warn_number_']").mouseover(function(){
			$(this).css('color','red');
		});
		$("span[id^='span_warn_number_']").mouseout(function(){
			$(this).css('color','black');
		});	
		$("span[id^='span_warn_number_']").click(function(){
			var goods_id=$(this).attr('id');
			goods_id=goods_id.substr('span_warn_number_'.length,goods_id.length-'span_warn_number_'.length);	
			
			$(this).hide();
			$("#input_warn_number_"+goods_id).show().focus();	
		});						
	});
	
</script>
{/if}

<!-- start goods list -->
<div class="list-div" id="listDiv">
<table  cellpadding="3" cellspacing="1">
  <tr>
    <th width="5%">{$lang.erp_goods_list_goods_id}</th>
    <th width="100">{$lang.erp_goods_list_goods_img}</th>
	<th width="10%">{$lang.erp_goods_list_goods_sn}</th>
	<th >{$lang.erp_goods_list_goods_name}</th>
	<th width="8%">{$lang.erp_goods_list_goods_warn_number}</th>	
	<th width="8%">{$lang.erp_goods_list_goods_number}</th>	
	<th width="15%">{$lang.erp_goods_list_goods_goods_attr}</th>
	<th width="10%">{$lang.erp_operation}</th>
  </tr>
  {foreach from=$goods_info key=key item=goods_info}
  <tr>
  	<td align="center">{$goods_info.goods_id}</td>
	<td align="center"><img width="100" height="100" src="{if $goods_info.goods_img}{$goods_info.goods_img}{else}images/no_img.gif{/if}" /></td>
	<td align="center">{$goods_info.goods_sn}</td>  
	<td>{$goods_info.goods_name}</td>    
	<td align="center">
		<span id="span_warn_number_{$goods_info.goods_id}">{$goods_info.warn_number}</span>
		<input type="text" id="input_warn_number_{$goods_info.goods_id}" value="{$goods_info.warn_number}" size="5" maxlength="5" style="display:none;" />
	</td> 
	<td align="center"><span style="{if $goods_info.goods_number gt $goods_info.warn_number}color:blue;font-weight:bold;{else}color:red;font-weight:bold;{/if}">{$goods_info.goods_number}</span></td> 
	<td align="center">
		{if $goods_info.goods_attr}
		<table>
		{foreach from=$goods_info.goods_attr key=key item=attr}
			<tr>
				<td width="45%">
						<table>
							<tr>
								{if $attr.goods_attr_id_list neq '$$'}
									<td width="50%">
										{foreach from=$attr.attr_value.attr_info item=attr_name}
											{$attr_name.attr_value}
										{/foreach}
									</td>
									<td>
										<span style="{if $attr.attr_value.goods_qty gt $goods_info.warn_number}color:blue;font-weight:bold;{else}color:red;font-weight:bold;{/if}">{$attr.attr_value.goods_qty}</span>
									</td>
								{else}
									<td>$$</td>
								{/if}
							</tr>
						</table>
				</td>
			</tr>
		{/foreach}
		</table>
		{/if}		
	</td> 
	<td align="center"><span id="span_set_warn_number_{$goods_info.goods_id}">{$lang.erp_goods_list_set_goods_warn_number}</span></td> 
  </tr> 
  {foreachelse}
  <tr><td class="no-records" colspan="9">{$lang.no_records}</td></tr>
 {/foreach}
  <tr><td colspan="9" align="right">{$page}</td></tr> 
</table>
</div>
<!-- end goods list -->

{literal}
<script language="JavaScript">
 
</script>
{/literal}
{include file="pagefooter.htm"}

